﻿using System.Collections;
using System.Collections.Generic;
using System.Web.Services;
using BLL;
using BLL.RF.PowerTest;
using BLL.RF.SourceCategory;
using Model.RF.PowerTest;
using Model.RF.SourceCategory;
using BLL.RF.TestRecord;
using Model.RF.TestRecord;

/// <summary>
///Source_FRGY_DataUploadAndProcessControl_Service 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class Source_FRGY_DataUploadAndProcessControl_Service : System.Web.Services.WebService
{
    private ProductType p;
    private TemperatureCheck tc;
    private VoltageCheck vc;
    private ProductType_Flow pf;
    public Source_FRGY_DataUploadAndProcessControl_Service()
    {
        p = new ProductType();
        tc = new TemperatureCheck();
        vc = new VoltageCheck();
        pf = new ProductType_Flow();
        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod(Description = "判断产品类型S代码是否合法，在数据上传之前调用")]
    public bool IsValidProductTypeID(string productTypeID)
    {
        return p.ProductType_Exist(productTypeID);
    }

    [WebMethod(Description = "电压测试数据录入时，判断之前工序是否有合格记录")]
    public bool ProductType_Flow_HasValidSevenStep_ForVoltageCheck(string productSN, string productTypeID)
    {
        return pf.ProductType_Flow_HasValidSevenStep(productSN, productTypeID, "VoltageCheckStep");
    }

    [WebMethod(Description = "FRGY产品电压检测工序，测试前关联管控，查询是否有最新的合格的功率测试数据")]
    public bool HasVilad_PowerTest(string productSN)
    {
        productSN = CommHelper.GetProductSN(productSN);
        PowerTest pt = new PowerTest();
        IList<PowerTestInfo> list = pt.GetPowerTestsbySN(productSN);
        if (list.Count > 0 && list[0].IsPass)
        {
            return true;
        }
        return false;
    }

    [WebMethod(Description = "FRGY产品电压检测工序检测数据上传")]
    public bool VoltageCheck_DataUpload(VoltageCheckInfo vci)
    {
        vci.ProductSN = CommHelper.GetProductSN(vci.ProductSN);
        return vc.Insert(vci);
    }

    [WebMethod(Description = "FRGY产品温度检测工序，测试前关联管控，查询是否有最新的合格的电压检测数据")]
    public bool HasVilad_VoltageCheck(string productSN)
    {
        productSN = CommHelper.GetProductSN(productSN);
        Test_Record tr = new Test_Record();
        IList<Test_RecordInfo> list = tr.Test_Record_GetVoltageCheck_bySN(productSN);
        if (list.Count > 0 && list[0].Result)
        {
            return true;
        }
        return false;
    }

    [WebMethod(Description = "FRGY产品温度检测工序检测数据上传")]
    public bool TemperatureCheck_DataUpload(TemperatureCheckInfo tci)
    {
        tci.ProductSN = CommHelper.GetProductSN(tci.ProductSN);
        return tc.Insert(tci);
    }

    //[WebMethod(Description = "FRGY产品ATE测试工序，测试前关联管控，查询是否有最新的合格的温度检测数据")]
    public bool HasVilad_TemperatureCheck(string productSN)
    {
        productSN = CommHelper.GetProductSN(productSN);
        IList<TemperatureCheckInfo> list = tc.TemperatureCheck_GetbyProductSN(productSN);
        if (list.Count > 0 && list[0].IsPass)
        {
            return true;
        }
        return false;
    }
}

